Seeed Studio XIAO ESP32-C5 first look - Scargill's Tech Blog

A small package of Seeed XIAO ESP32 boards has arrived here in sunny Galera for me, and the first thing that caught my eye was the provision for a battery and an external RF antenna.In case anyone is wondering, XIAO is pronounced “SHYOW” or near enough.This is a very interesting little board for battery-powered projects, particularly where the device can spend most of its life asleep and wake only when something happens.

The board This is the Seeed Studio XIAO ESP32-C5.The ESP32-C5 is a single-core 32-bit RISC-V device running at up to 240 MHz, with 8 MB PSRAM and 8 MB Flash.No pretty blue sky photos this time – the AI completely messed them up so back to old-school photography The XIAO C5 supports: 2.4 GHz and 5 GHz dual-band Wi-Fi 6 Bluetooth 5 LE Zigbee 3.0 Thread 1.4 I2C, SPI and UART Up to 11 GPIOs Five ADC channels JTAG connections on the rear pads On-board battery charging and battery-voltage measurement The board is the familiar XIAO size, just 21 × 17.8 mm.

The external antenna These boards have a tiny U.FL-R-SMT1 connector for the RF antenna.I’ve always thought of these as painful but when making my recent letterbox alert it did occur to me that and external antenna for the LoRa would be handy instead of putting the while lot outside of the letterbox – but I digress.The good news is that the boards are supplied with an antenna.

The antenna supplied with these is marked “XIAO FPC Antenna A-01”.So, in practice, I don’t need to go hunting for a suitable antenna before testing them.The antenna connection is important for normal RF operation.

Although the ESP32-C5 itself will obviously power up and run without the antenna connected, I would not deliberately operate the radio without a suitable antenna attached.The ESP32-C5 supports both 2.4 GHz and 5 GHz Wi-Fi, so the antenna needs to be suitable for the frequencies being used.Those battery pads On the underside of the board are two clearly marked battery pads: – BAT + These are intended for a 3.7 V lithium battery.

The board includes an SGM40567 battery charging IC, and Seeed also provides circuitry for measuring the battery voltage.The battery voltage measurement uses GPIO6, with GPIO26 controlling the measurement circuit so that it can be disabled when it isn’t required in order to save power.Seeed states that the XIAO ESP32-C5 can remain connected to a computer over USB while a battery is connected, thanks to the board’s built-in battery protection/management circuitry.

Obviously, the battery polarity needs to be observed carefully when soldering to the pads.Is the battery connection really for sleep mode? Not specifically.The battery pads simply provide the means of powering the board from a battery.

Sleep mode is a function of the ESP32-C5 firmware, however, the combination of a battery connection and the very low deep-sleep current makes this board particularly interesting for battery-powered sensors.Seeed provides a working deep-sleep example in which D0 (GPIO1 / LP_GPIO1) is used to wake the ESP32-C5.The board also supports timer wake-up.

One useful warning from Seeed is that the JTAG pins — MTMS, MTDI, MTCK and MTDO — should preferably be kept for JTAG rather than being used as deep-sleep wake-up pins during development.Also, once the XIAO enters deep sleep, its USB port disappears.It has to wake again before the USB port becomes visible.

Power consumption This is where things get interesting…the ESP32-C5 datasheet gives the following typical chip currents: These are ESP32-C5 chip figures, measured from a 3.3 V supply under the conditions specified by Espressif.They should not automatically be treated as the complete current consumption of a finished battery-powered project.The awake current is a completely different matter.

For example, the ESP32-C5 datasheet gives peak Wi-Fi transmission currents as high as approximately 339 mA at 2.4 GHz and 381 mA at 5 GHz, depending on the transmission mode and power level.That means the important figure for a real battery project is the average current over time, not simply the deep-sleep figure… for example, a sensor which sleeps at around 12 µA for most of the time, wakes for a short period, connects to Wi-Fi, sends a message and immediately goes back to sleep could have a very low average consumption.That’s precisely the sort of application I have in mind for these boards.

A useful distinction: light sleep versus deep sleep Light sleep leaves considerably more of the system available and can wake quickly.Deep sleep shuts down the CPUs and most of the digital peripherals, leaving the RTC system and low-power memory running.For a simple battery sensor that only needs to wake when a switch changes state, or at regular intervals, deep sleep is the interesting mode.

The ESP32-C5 also contains a separate low-power RISC-V processor, which opens up some interesting possibilities for applications that need low-power processing while the main processor is asleep.What I want to test Rather than simply accepting the 12 µA figure from the datasheet, the obvious next step is to measure one of these actual XIAO ESP32-C5 boards.I’d like to establish: Current consumption while running normally.

Current consumption in light sleep.Current consumption in deep sleep.Current drawn when waking and using Wi-Fi.

How quickly it wakes from deep sleep.How practical it is to use a GPIO as a wake-up input.Ultimately, the average current of a real battery-powered sensor.

That will give a much more useful battery-life figure than simply dividing battery capacity by the advertised deep-sleep current.Why this board caught my attention The combination is rather compelling: a tiny 21 × 17.8 mm board, dual-band Wi-Fi 6, Bluetooth LE, Zigbee and Thread, battery charging, an external antenna connection and a quoted ESP32-C5 deep-sleep current of only 12 µA.For something which normally has to be awake all the time, that isn’t particularly exciting but for something which might sit in a letterbox, gate, shed, garden, cupboard or other remote location for months and only wake when required, it could be very interesting indeed.

The next step is therefore obvious: get one onto the bench, put a battery on those BAT pads, and measure what the complete Seeed board actually consumes.Sources Seeed Studio – XIAO ESP32-C5 Getting Started:https://wiki.seeedstudio.com/xiao_esp32c5_getting_started/ Espressif ESP32-C5 Series Datasheet:https://files.seeedstudio.com/wiki/XIAO_ESP32C5/res/esp32-c5_datasheet_en.pdf Attempt 1 – 2.4G or 5G WiFi One has to start somewhere – and with ESPHOME that’s quite easy.I made suer I had 2 WiFi SSIDs availabel comfast and comfast5g (for obvious reasons) – same password which I keep in an ESPHOME secrets file.

Here is the intial code – which worked a treat first time around (with ESPHOME you flash the chip ovre serial the first time – and from then onwards you can use WiFi.############################################################################### # Seeed Studio XIAO ESP32-C5 # # First test firmware - version 0.1 # # What this version does: # - Connects to the 2.4 GHz "comfast" Wi-Fi network initially # - Provides a Web UI # - Provides the Home Assistant ESPHome API # - API encryption is deliberately NOT enabled # - Measures the voltage of a connected Li-ion battery # - Provides a Web UI selector to switch between: # comfast = 2.4 GHz # comfast5g = 5 GHz # - Displays Wi-Fi signal strength # - Displays firmware version # # What this version deliberately DOES NOT do: # - No deep sleep # - No external I/O # - No sensors other than battery voltage # # Deep sleep will be added after we have tested both Wi-Fi bands and measured # actual battery behaviour.############################################################################### substitutions: device_name: xiao-esp32-c5 friendly_name: "XIAO ESP32-C5" firmware_version: "0.1" esphome: name: ${device_name} friendly_name: ${friendly_name} comment: "Seeed Studio XIAO ESP32-C5 - Wi-Fi and battery test" project: name: "pete.xiao_esp32_c5" version: ${firmware_version} ############################################################################### # ESP32-C5 ############################################################################### esp32: board: esp32-c5-devkitc-1 framework: type: esp-idf ############################################################################### # Logging ############################################################################### logger: ############################################################################### # Home Assistant API # # Deliberately NO encryption.

############################################################################### api: ############################################################################### # OTA updates ############################################################################### ota: - platform: esphome ############################################################################### # Wi-Fi # # We start on the 2.4 GHz network.# # AUTO allows the ESP32-C5 to use either supported band.The Web UI selector # below chooses which of our two SSIDs it connects to.

############################################################################### wifi: ssid: "comfast" password: !secret wifi_password band_mode: AUTO # Give the C5 a little time to reconnect after changing Wi-Fi network.reboot_timeout: 15min ############################################################################### # Web interface # # Version 2 is the current ESPHome web interface.# "local: true" means the supporting web files are stored on the ESP itself.

############################################################################### web_server: port: 80 version: 3 local: true ############################################################################### # Basic status ############################################################################### text_sensor: # Our own project/firmware version.# This is deliberately separate from the ESPHome version.- platform: template name: "Firmware Version" lambda: |- return {"0.1"}; update_interval: 60s icon: "mdi:tag" # Shows the Wi-Fi network to which the C5 is currently connected.

- platform: wifi_info ssid: name: "WiFi SSID" web_server: sorting_weight: 10 ip_address: name: "IP Address" web_server: sorting_weight: 11 sensor: ########################################################################### # Wi-Fi signal strength ########################################################################### - platform: wifi_signal name: "WiFi Signal" update_interval: 10s unit_of_measurement: "dBm" accuracy_decimals: 0 icon: "mdi:wifi" web_server: sorting_weight: 20 ########################################################################### # Battery voltage # # Seeed's XIAO ESP32-C5 uses: # # GPIO26 = enable battery measurement circuit # GPIO6 = ADC battery voltage input # # The hardware uses a 1:2 voltage divider, so the ADC voltage is doubled.########################################################################### - platform: adc pin: GPIO6 name: "Battery Voltage" id: battery_voltage attenuation: auto update_interval: 10s unit_of_measurement: "V" device_class: voltage state_class: measurement accuracy_decimals: 2 filters: - multiply: 2.0 icon: "mdi:battery" web_server: sorting_weight: 30 ############################################################################### # Battery measurement enable # # GPIO26 controls the battery-voltage measurement circuit on the XIAO C5.# We leave it enabled in this first version because we are not yet trying # to minimise battery consumption.

############################################################################### output: - platform: gpio pin: GPIO26 id: battery_measurement_enable switch: - platform: output name: "Battery Measurement Enable" id: battery_measurement_switch output: battery_measurement_enable restore_mode: ALWAYS_ON entity_category: diagnostic web_server: sorting_weight: 40 ############################################################################### # Wi-Fi band/network selector # # This is deliberately simple.# # Selecting "2.4 GHz" connects to: # comfast # # Selecting "5 GHz" connects to: # comfast5g # # Both use the same password stored in secrets.yaml.# # Changing networks will temporarily disconnect the Web UI and Home # Assistant API while the C5 reconnects.

############################################################################### select: - platform: template name: "WiFi Network" id: wifi_network icon: "mdi:wifi-cog" optimistic: true restore_value: true options: - "2.4 GHz" - "5 GHz" initial_option: "2.4 GHz" set_action: - if: condition: lambda: 'return x == "2.4 GHz";' then: - logger.log: "Switching Wi-Fi to 2.4 GHz - comfast" - wifi.configure: ssid: "comfast" password: !secret wifi_password save: true timeout: 30s else: - logger.log: "Switching Wi-Fi to 5 GHz - comfast5g" - wifi.configure: ssid: "comfast5g" password: !secret wifi_password save: true timeout: 30s web_server: sorting_weight: 5 and the resultant WebUI which works in a browser – same address as the ESP itself – port 80 unless otherwise specified.And it WORKED.The board powered up on ssid “comfast” and when I changed the dropdown to 5Ghz it switched to the 5Ghz WiFi “comfast5g” (browser refresh needed at that point).

Battery voltage, signal strength, ssid, IP address – signal strength – all you need to start the ball rolling.Unimpressed? Most ESPs and other IOT devices cannot access the 5Ghz band and that 2.4Ghz band gets crowded quite quickly.Of course I wanted to be complete – so flicked back to 2.4Ghz Another refresh to see the results..

Note the signal strength… Next I’ll do some low power testing but not bad for a simple start… With one simple addition to my sensor section – I added the up-time indicator – handy to know when experimenting..# How long the C5 has been running since its last restart.- platform: uptime name: "Uptime" update_interval: 10s icon: "mdi:timer-outline" And just like that… One last thing for tonight – the 4.00v is because I’m running the board off one of my PC USB ports… and to touch right now, the board is only slightly warm.

Then I discovered this in the log – apparently there are default ESP settings which time out the ESP32-C5 if no clients – I don’t want it turning off when I’m testing so… slight mod to API and WiFi sections… ### Reboot timeout 0 to stop it rebooting if no clients while testing api: reboot_timeout: 0s ############################################################################### # Wi-Fi # # We start on the 2.4 GHz network.# # AUTO allows the ESP32-C5 to use either supported band.The Web UI selector # below chooses which of our two SSIDs it connects to.

############################################################################### wifi: ssid: "comfast" password: !secret wifi_password band_mode: AUTO # no timeout while testing.reboot_timeout: 0s In each case the reboot_timeout is the change which stops the unit timing out.Since making those 2 changes, the unit has been on for 10 hours overnight including a change from 2.4Ghz WiFi to 5Ghz WiFi using the WebUI.

Note that while the ESP32-C5 seems like a big upgrade, the ESP32-S3 has more RAM but the former is still streets ahead of the likes of the common ESP32-C3.If you read my article about the C3-based Abrobot unit with tiny display – I have it running side by side with the C5 right now on test – if both are on 2.4Ghz WiFi fairly close to my office router, note that I’m getting a -17dBm WiFi signal on the C5, but a -50dBm signal on the C3.I originally had horrendous problems getting a signal on the C3 from my hallway and had to introduce a WiFi access point actually in my office to get satisfactory operation.

That’s absolutely not going to be needed for the C5 – OK the external antenna would be a pain in small projects to be sure but that’s a CONSIDERABLE signal difference if space isn’t an issue.More soon…

Read More
Related Posts